package cn.lingyangwl.agile.demo.dynamic_bean;

import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;

/**
 * @author shenguangyang
 */
@Component
public class MyBean01 {
    @Resource
    private MyBean02 myBean02;

    private String str;

    private List<String> data = new ArrayList<>();

    @PostConstruct
    public void init() {
        System.out.println("init");
    }

    public void setStr (String str) {
        this.str = str;
    }

    public String getStr() {
        return this.str;
    }

    public void doSomething () throws InterruptedException {
        System.out.println("from MyBean01 - " + str);
        myBean02.doSomething();
        for (int i = 0; i < 10; i++) {
            data.add(i + "");
            TimeUnit.MILLISECONDS.sleep(20);
            data.get(i);
        }
        data.clear();
    }
}
